#ifndef __SALT_GRAPHICS_H
#define __SALT_GRAPHICS_H
#include "SALT_Config.h"

#include "Points.h"

#include "SALT_Events.h"

#include <stack>

struct SDL_Surface;
typedef struct SDL_Surface SDL_Surface;
struct SDL_Rect;
typedef struct SDL_Rect SDL_Rect;

namespace SALT{
	namespace Graphics{

		class Color{
		public:
			unsigned char r;
			unsigned char g;
			unsigned char b;
		};

		/*
		* Abstract drawing and chiz
		*/
		template <typename _T> class _AbstractGraphicsManager{
		protected:
			SALT::Events::_AbstractEventManager*	_eventManager;
		public:
			_AbstractGraphicsManager(){this->_eventManager=NULL;}
			~_AbstractGraphicsManager(){}
			SALT::Events::_AbstractEventManager*&	eventManager(){return this->_eventManager;}
			virtual void	drawLine	(Point& p1,Point& p2,unsigned short r,unsigned short b,unsigned short g,unsigned short a)=0;
			virtual void	drawRect	(Point& tlCorner,Point& brCorner,unsigned short r,unsigned short b,unsigned short g,unsigned short a)=0;
			virtual void	drawEllipse	(Point& center,int vAxisLength,int hAxisLength,unsigned short r,unsigned short b,unsigned short g,unsigned short a)=0;
			virtual void	blit		(_T surf,Point& pos,Point* size=NULL)=0;
			virtual void	handleEvent	(void* data)=0;
		};

		class SDLGraphicsManager: public _AbstractGraphicsManager<SDL_Surface*>{
		protected:
			bool					_initedSDL;
			SDL_Surface*			_screen;
			std::stack<Point*>		_clips;
			Point					_addClip(Point* p);
		public:
			SDLGraphicsManager();
			SDLGraphicsManager(unsigned int screenWidth,unsigned int screenHeight,unsigned int bpp,unsigned int flags);
			~SDLGraphicsManager();
			void			drawLine	(Point& p1,Point& p2,unsigned short r,unsigned short b,unsigned short g,unsigned short a);
			void			drawRect	(Point& tlCorner,Point& brCorner,unsigned short r,unsigned short b,unsigned short g,unsigned short a);
			void			drawEllipse	(Point& center,int vAxisLength,int hAxisLength,unsigned short r,unsigned short b,unsigned short g,unsigned short a);
			void			blit		(SDL_Surface* surf,Point& pos,Point* size=NULL);
			void			handleEvent	(void* data);
			void			pushClip	(Point* clip);
			Point*			popClip		();
			void			flip		();
			void			clear		();
		};
	};
};

#endif